package com.netty.model.netty;

import io.netty.channel.Channel;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

/**
 * 用户id和channel的关联关系处理
 */
@Data
@Slf4j
public class UserChannelRel {

    private static HashMap<String, Channel> mannager = new HashMap<>();

    public static void put(String sendUserId, Channel channel) {
        mannager.put(sendUserId, channel);
    }

    public static Channel get(String sendUserId) {
        return mannager.get(sendUserId);
    }

    public static void output() {
        for (HashMap.Entry<String, Channel> entry : mannager.entrySet()) {
            log.info("连接的管道userId=" + entry.getKey() + "，channelId=" + entry.getValue().id().asLongText());
        }
    }

}
